package com.system.module.admin.controller;


import java.io.IOException;
import java.util.Arrays;
import java.util.List;

import com.system.framework.aspect.lang.annotation.Log;
import com.system.framework.aspect.lang.enums.BusinessType;
import com.system.common.result.R;
import io.swagger.annotations.Api;
import com.system.module.admin.entity.ApTest;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import com.system.common.page.PageInfo;
import org.springframework.web.bind.annotation.*;
import lombok.extern.slf4j.Slf4j;
import com.system.module.admin.service.IApTestService;
import com.system.module.admin.request.ApTestRequest;

import javax.servlet.http.HttpServletResponse;

/**
 * 测试2控制层
 *
 * @author mars
 * @date 2024-04-13
 */
@Slf4j
@AllArgsConstructor
@RestController
@Api(value = "测试2接口管理", tags = "测试2接口管理")
@RequestMapping("/admin/test")
public class ApTestController {

    private final IApTestService iApTestService;

    /**
     * 分页查询测试2列表
     */
    @ApiOperation(value = "分页查询测试2列表")
    @PostMapping("/pageList")
    public R<PageInfo<ApTest>> pageList(@RequestBody ApTestRequest apTestRequest) {
        return R.success(iApTestService.pageList(apTestRequest));
    }

    /**
     * 获取测试2详细信息
     */
    @ApiOperation(value = "获取测试2详细信息")
    @GetMapping(value = "/query/{id}")
    public R<ApTest> detail(@PathVariable("id") Long id) {
        return R.success(iApTestService.getById(id));
    }

    /**
     * 新增测试2
     */
    @Log(title = "新增测试2", businessType = BusinessType.INSERT)
    @ApiOperation(value = "新增测试2")
    @PostMapping("/add")
    public R<Void> add(@RequestBody ApTestRequest apTestRequest) {
        iApTestService.add(apTestRequest);
        return R.success();
    }

    /**
     * 修改测试2
     */
    @Log(title = "修改测试2", businessType = BusinessType.UPDATE)
    @ApiOperation(value = "修改测试2")
    @PostMapping("/update")
    public R<Void> edit(@RequestBody ApTestRequest apTestRequest) {
        iApTestService.update(apTestRequest);
        return R.success();
    }

    /**
     * 删除测试2
     */
    @Log(title = "删除测试2", businessType = BusinessType.DELETE)
    @ApiOperation(value = "删除测试2")
    @DeleteMapping("/delete/{ids}")
    public R<Void> remove(@PathVariable Long[] ids) {
        iApTestService.deleteBatch(Arrays.asList(ids));
        return R.success();
    }

}
